package org.gongliang.jsmile.config.excel.style;


import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;


/**
 * 默认实现的excel样式
 * 
 * @author Morily
 *
 */
public class DeafultExcelStyle implements ExcelStyle {

	@Override
	public CellStyle getTitleStyle(Sheet sheet) {
		CellStyle titleStyle = sheet.getWorkbook().createCellStyle();
		titleStyle.setAlignment(HorizontalAlignment.CENTER);
		titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中
		return titleStyle;
	}

	@Override
	public CellStyle getHeaderStyle(Sheet sheet) {
		CellStyle titleStyle = sheet.getWorkbook().createCellStyle();
		titleStyle.setAlignment(HorizontalAlignment.CENTER);
		titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中
		return titleStyle;
	}

	@Override
	public CellStyle getContentStyle(Sheet sheet) {
		CellStyle style = sheet.getWorkbook().createCellStyle();
		style.setAlignment(HorizontalAlignment.CENTER);
		style.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中
		style.setWrapText(true);
		return style;
	}

}
